-
Notifications
You must be signed in to change notification settings - Fork 213
Introduce wc_stripe_force_save_payment_method
filter
#4243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
📈 PHP Unit Code Coverage Report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is working for me, but I have objections to the UX, specifically this sequence (emphasis mine):
- As a shopper purchase a product with card. Make sure the
Save payment information to my account for future purchases
checkbox is not selected.- Go to My Account > Payment methods page as the shopper and confirm that the card is saved this time.
While saving their payment method is something a merchant may really want to do, giving the user no indication that this will happen doesn't feel right. Can we instead include the return value of the filter to the UI and ensure that the checkbox is checked and disabled when the value is true?
I see we already have logic to hide the checkbox when we want to force saving the payment method (which we're not using in this PR), but that also feels problematic given that there's no indication that the payment method will be saved.
woocommerce-gateway-stripe/includes/abstracts/abstract-wc-stripe-payment-gateway.php
Lines 125 to 143 in 7bd0453
/** | |
* Displays the save to account checkbox. | |
* | |
* @since 4.1.0 | |
* @version 5.6.0 | |
*/ | |
public function save_payment_method_checkbox( $force_checked = false ) { | |
$id = 'wc-' . $this->id . '-new-payment-method'; | |
?> | |
<fieldset <?php echo $force_checked ? 'style="display:none;"' : ''; /* phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped */ ?>> | |
<p class="form-row woocommerce-SavedPaymentMethods-saveNew"> | |
<input id="<?php echo esc_attr( $id ); ?>" name="<?php echo esc_attr( $id ); ?>" type="checkbox" value="true" style="width:auto;" <?php echo $force_checked ? 'checked' : ''; /* phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped */ ?> /> | |
<label for="<?php echo esc_attr( $id ); ?>" style="display:inline;"> | |
<?php echo esc_html( apply_filters( 'wc_stripe_save_to_account_text', __( 'Save payment information to my account for future purchases.', 'woocommerce-gateway-stripe' ) ) ); ?> | |
</label> | |
</p> | |
</fieldset> | |
<?php | |
} |
Fixes STRIPE-229
Fixes #3502
Changes proposed in this Pull Request:
Testing instructions
Enable payments via saved cards
.Save payment information to my account for future purchases
checkbox is not selected.Save payment information to my account for future purchases
checkbox is not selected.Save payment information to my account for future purchases
checkbox is not selected.Save payment information to my account for future purchases
works as before.Note
I will add a changelog under
9.6.0
.